<?php
class defaultComponents extends sfComponents{
    public function executeReplyRanking()
    {
        //返信の多いコメントをランキング形式で出力

        // /lib/model/ReplyPeer.phpと紐づいている
        $result = ReplyPeer::countCommentId();

        $arr = array();
        foreach($result as $value){
            if(CommentPeer::retrieveByPK($value["COMMENT_ID"])){
                $arr[$value["COMMENT_ID"]] = $value["COUNT(COMMENT_ID)"];
            }
        }
        arsort($arr);
        $this->replyranks = array();
        $cnt = 0;
        foreach($arr as $k => $v){
            $this->replyranks[]=array("cnt" => $v, "obj" => CommentPeer::retrieveByPK($k));
            $cnt++;
            if($cnt >= 5){
                break;
            }
        }
        //print_r($this->replyranks);exit;

        //return sfView::SUCCESS;
    }
}









?>



